<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Step_ao extends MY_Controller 
{

    public function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
        $this->load->helper('common');
        $this->load->model('welcome_model');
    }

	
    /*
    *获取产品列表
    */
    public function get_ao_product_api()
    {
         $proarr = $this->welcome_model->get_pro(); 
         
        if(!$proarr)
        {
            error_output('当前没有产品');
        }
        $resu['status'] = 1;

        foreach ($proarr as $key => $val) {
            $resu['pro_List'][$key] = array(
				'proId' => $val['id'],  //产品ID
				'proName' => $val['proname'], //产品名称
				'proDesc' => $val['prodesc'],   //产品描述
				'proImg' => $val['proimg'],   //产品图片
				'effect' => $val['effect'],   //产品图片
        	);
        }
       json_output($resu);
         
    }
    
    /*
    *获取单个产品的内容
    */
    public function get_pro_content_api()
    {
        $id= $this->input->get('id');
        $proInfo = $this->welcome_model->get_pro_content($id);
        $proOtherInfo = $this->welcome_model->get_otherpro_content($id);
        $proInfo['other'] = $proOtherInfo;
        if(!$proInfo){
            error_output('产品信息有误');
        }
        json_output($proInfo);
    }
    
    /*
    *取的单个产品放在首页
    */
      public function get_pro_contentone_api()
    {
        
        $proInfo = $this->welcome_model->get_pro_contentone();
       if(!$proInfo){
            error_output('产品信息有误');
        }
        json_output($proInfo);
    }
    
     public function get_pro_ajaxcontentone_api()
    {
        
        $proid = $this->input->get('proid');
        $type = $this->input->get('type');
        
        $proInfo = $this->welcome_model->ajaxget_pro_contentone($proid, $type);
        if(!$proInfo){
            error_output('产品信息有误');
        }
        json_output($proInfo);
        
    }
 
     /*
    *首页-获取（关于他们）列表信息
    */
    public function get_withOther_api()
    {
        $ppage = $this->input->get('ppage') ? $this->input->get('ppage')  : 1;
        if(isset($_GET['type'])){
           $type = $_GET['type'];
        }else{
           $type=false;
        }
        $withOther = $this->welcome_model->get_with_list($type, $ppage);
      
        if(!$withOther){
            error_output('无关于他们图片信息');
            
        }
        $resu['status'] = 1;
        $resu['page'] = $withOther['page'];
        unset($withOther['page']);
        //preg_match('/<img.+src=\"?(.+\.(jpg|gif|bmp|bnp|png))\"?.+>/i',$rowarr['post_content'],$match);
        foreach($withOther as $k=>$v){
            $resu['with_list'][$k]  = array(
                'withId' => $v['ID'],
                'withName' => $v['post_title'],
                'withImg' => $v['img'],
                'Imgurl' => $v['imgurl'],
                'withDesc' => $v['post_content'],
            );
        }
         json_output($resu);
         
    }
    /*
    *取的患者个人信息
    */
    public function get_rowOther_api()
    {
        $id = $this->input->get('id');
        $rowArr = $this->welcome_model->get_rowOther($id);
        if(!$rowArr){
            error_output('用户信息有误');
        }
        $resu['status'] = 1;
        $resu['row_arr'] = $rowArr;
        json_output($resu);
    }
    
    /*
    *取的搜索文章
    */
    
    public function get_searchArticle_api()
    {
        $searchID = $this->input->get('search');
        $ppage = $this->input->get('ppage');
        $result = $this->welcome_model->get_search_article($searchID,$ppage);
        
        if(!$result){
            error_output('搜索失败');
        }
        
        $resu['status'] = 1;
        $resu['page'] = $result['page'];
        unset($result['page']);
        foreach($result as $k=>$v){
            $resu['searchList'][$k]=array(
                'articleContent'=>strip_tags(preg_replace('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', '', $v['post_content'])),
                'articleDate'=> $v['post_date'],
                'articleTitle'=> $v['post_title'],
                'articleID'=> $v['ID']
                
            );
        }
        
        json_output($resu);
        
    }
    
    /*
    *首页的专业名词名称展示
    */
    public function get_noun_name_api()
    {
        $noun = $this->welcome_model->get_nounname_list();
        json_output($noun);
        /*
        if(!$noun){
            error_output('专业名词库无信息');
        }
        
        $resu['status'] = 1;
        foreach($noun as $k=>$v){
            $resu['noun_list'][$k]=array(
                ''=>,
             );
        }
        
        return $resu;
        */
    }
    
    /*
    *分组后的专业名词显示
    */
    public function get_moreNoun_name_api()
    {
        $moreNoun = $this->welcome_model->get_moreNounName_list();
        //$moreNoun = array(2,2,2,2,2);
        json_output($moreNoun);
    }
    
    
 }
